// packageJ/capital_pool/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 0,
    avatar: "",
    nickname: "",
    amounts: 0,
    page:1,
    total_page:1,
    list:[],
    uid:'',
    language:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    let language = wx.getStorageSync('langIndex');
    let uid = wx.getStorageSync('yz_uid');
    this.setData({uid,'language': language.en,});
    this.getData();
  },
  onClick(){
    this.getData();
  },
  getData(page=1){
    app._getNetWork({
      url:app.getNetAddresss("plugin.tx-bonus-pool.frontend.controllers.center"),
      data:{page},
      success:resdata=>{
        let {result,msg,data} = resdata.data;
        if(result){
          let { plugin_name, avatar, amounts, nickname } = data.info;
          wx.setNavigationBarTitle({
            title: plugin_name,
          })
          this.data.page = data.list.current_page;
          this.data.total_page = data.list.last_page;
          if(page==1){
            this.setData({list:data.list.data||[]})
          }else{
            let list = this.data.list.concat(data.list.data);
            this.setData({list})
          }
          this.setData({
            avatar,amounts,nickname
          })
        }else{
          app.tips(msg);
        }
      }
    })
  },  

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if(this.data.page>=this.data.total_page){
      return;
    }
    let page = this.data.page+1;
    this.getData(page);
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})